//
//  AssemblingPlaceView.m
//  UIViewTap
//
//  Created by dllo on 16/9/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "AssemblingPlaceView.h"
#import "UIImageView+WebCache.h"
#import "Assemblingplace.h"

@interface AssemblingPlaceView ()
@property (strong, nonatomic) UIImageView *picImage;
@property (strong, nonatomic) UILabel *locateLabel;
@property (strong, nonatomic) UILabel *addressLabel;
@property (strong, nonatomic) UIImageView *nextImage;
@property (strong, nonatomic) UILabel *yueyouCountLabel;

@end

@implementation AssemblingPlaceView

- (void)setAssemblePlace:(Assemblingplace *)assemblePlace {
    _assemblePlace = assemblePlace;
    
    [_picImage sd_setImageWithURL:[NSURL URLWithString:_assemblePlace.PicUrl]];
    [_picImage sizeToFit];
    
    _locateLabel.text = [NSString stringWithFormat:@"集合地: %@", _assemblePlace.Locate];
    [_locateLabel sizeToFit];
    
    _addressLabel.text = [NSString stringWithFormat:@"位于: %@", _assemblePlace.Address];
    [_addressLabel sizeToFit];
    
    _nextImage.image = [UIImage imageNamed:@"cell_next"];
    [_nextImage sizeToFit];
    
    _yueyouCountLabel.text = [NSString stringWithFormat:@"%ld人在此结伴", (long)_assemblePlace.YueyouCount];
    [_yueyouCountLabel sizeToFit];
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor colorWithWhite:0.961 alpha:1.000];
        
        _rootLayout = [MyRelativeLayout new];
        _rootLayout.widthDime.equalTo(self.widthDime);
        _rootLayout.heightDime.equalTo(self.heightDime);
        [self addSubview:_rootLayout];
        
        _picImage = [UIImageView new];
        _picImage.topPos.equalTo(_rootLayout.topPos);
        _picImage.leftPos.equalTo(_rootLayout.leftPos);
        _picImage.bottomPos.equalTo(_rootLayout.bottomPos);
        _picImage.widthDime.equalTo(_rootLayout.heightDime);
        [_rootLayout addSubview:_picImage];
        
        _locateLabel = [UILabel new];
        _locateLabel.topPos.equalTo(_rootLayout.topPos);
        _locateLabel.leftPos.equalTo(_picImage.rightPos).offset(10);
        _locateLabel.rightPos.equalTo(_rootLayout).offset(10);
        _locateLabel.heightDime.equalTo(_rootLayout.heightDime).multiply(1 / 3.0);
        _locateLabel.font = [UIFont systemFontOfSize:19.f];
        [_rootLayout addSubview:_locateLabel];

        _nextImage = [UIImageView new];
        _nextImage.rightPos.equalTo(_locateLabel.rightPos);
        _nextImage.topPos.equalTo(_locateLabel.bottomPos);
        _nextImage.heightDime.equalTo(_locateLabel.heightDime);
        _nextImage.widthDime.equalTo(_nextImage.heightDime).multiply(4/5.0);
        [_rootLayout addSubview:_nextImage];
        
        _addressLabel = [UILabel new];
        _addressLabel.topPos.equalTo(_locateLabel.bottomPos);
        _addressLabel.leftPos.equalTo(_locateLabel.leftPos);
        _addressLabel.rightPos.equalTo(_nextImage.leftPos);
        _addressLabel.heightDime.equalTo(_nextImage.heightDime);
        _addressLabel.font = [UIFont systemFontOfSize:16.f];
        [_rootLayout addSubview:_addressLabel];
        
        _yueyouCountLabel = [UILabel new];
        _yueyouCountLabel.topPos.equalTo(_addressLabel.bottomPos);
        _yueyouCountLabel.leftPos.equalTo(_addressLabel.leftPos);
        _yueyouCountLabel.widthDime.equalTo(_addressLabel.widthDime);
        _yueyouCountLabel.heightDime.equalTo(_addressLabel.heightDime);
        _yueyouCountLabel.font = [UIFont systemFontOfSize:16.f];
        _yueyouCountLabel.textColor = [UIColor colorWithWhite:0.565 alpha:1.000];
        [_rootLayout addSubview:_yueyouCountLabel];
        
    }
    return self;
}


@end
